Capturing still video or motion video being out of focus in interesting portions of the camera view may be quite annoying. This may for example be a result of the camera focusing at a different portion of the camera view or the camera not focused at any object or subject of the camera image view at all.
There have been developed and suggested quite a lot of automatic focusing schemes to address this problem. The two main approaches are referred to as active autofocus and passive autofocus, respectively. The active autofocus schemes include measuring the distance to the subject to be captured and adjusting the focus of the camera accordingly. The measuring is generally performed by emitting for instance ultrasonic sound waves or infrared light. The passive autofocus schemes generally include passive analysis of light from the image view entering the camera. Passive autofocus schemes may be based on phase detection or contrast detection. Most contrast detection schemes include calculating a focus value, i.e. a focus measure, of the captured camera view and then determining if the focus value indicates a sharp image. In most focus schemes the process include the calculation of a plurality of focus values at a plurality of different lens distances and based on this plurality or data points determine at which lens distance a focus value indicating a sharp image is achieved. The process is often iterative. The lens distance being a spatial relation between a focus plane of the camera and a lens/lenses of the camera lens. Accordingly, the lens distance is the property of the lens that is changed when the focus of the camera/lens is changed from an object nearby to an object further away and vice versa.
One commonly used method for finding the best sharpness is a one dimensional search procedure for finding a maxima or minima of a curve called line search. This is of great interest when dealing with Auto Focus, since the objective is to find the lens distance which generates the largest focus value along the lens position axis. The line search method applied in an autofocus scheme results in a scheme that requires few iterations and is stable. There are a number of line search methods, which are guaranteed to converge within a finite and rather low number of iterations. Two such fast methods are Golden Section search and Fibonacci search. These work by a construction of diminishing intervals obtained by comparing boundary points with inner points and then moving boundary points to inner points in an iterative manner.
Another family of frequently used methods for finding the lens distance resulting in the sharpest image are hill climbing algorithms with adaptive step size. Hill climbing algorithms operates by stepping through the curve in a consecutive way. The step size is often adjusted according to focus value thresholds so that a focus motor takes smaller steps when in the proximity of a maximum.